package com.frank.twloading.slice;

import com.frank.loadinglibrary.common.*;
import com.frank.loadinglibrary.common.element.*;
import com.frank.loadinglibrary.common.gear.GearElement;
import com.frank.loadinglibrary.special.element.*;
import com.frank.twloading.ComponentItemProvider;
import com.frank.twloading.ResourceTable;
import ohos.aafwk.content.Intent;
import ohos.agp.colors.RgbColor;
import ohos.agp.components.Component;
import ohos.agp.components.ListContainer;
import ohos.agp.components.TableLayoutManager;
import ohos.agp.components.element.ShapeElement;

import java.util.ArrayList;

public class NormalAbilitySlice extends BaseSlice {

    private ArrayList<Component> items;

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_normal);
        initData();
        ShapeElement element = new ShapeElement();
        element.setRgbColor(new RgbColor(231, 87, 100));


        ListContainer listContainer = getComponentById(ResourceTable.Id_listContainer);
        TableLayoutManager tableLayoutManager = new TableLayoutManager();
        tableLayoutManager.setColumnCount(4);
        listContainer.setLayoutManager(tableLayoutManager);
        listContainer.setBackground(element);
        listContainer.setItemProvider(new ComponentItemProvider(items, 4));


    }

    private void initData() {
        items = new ArrayList<>();
        FactoryComponent ballSwing = new FactoryComponent(this);
        ballSwing.config(new BallSwingElement.BallSwingBuilder(ballSwing).build());
        items.add(ballSwing);
        FactoryComponent cubeGrid = new FactoryComponent(this);
        cubeGrid.config(new CubeGridElement.CubeGridBuilder(cubeGrid).build());
        items.add(cubeGrid);
        FactoryComponent ballFading = new FactoryComponent(this);
        ballFading.config(new BallFadingElement.BallFadingBuild(ballFading).build());
        items.add(ballFading);
        FactoryComponent doubleCircle = new FactoryComponent(this);
        doubleCircle.config(new DoubleCircleElement.Builder(doubleCircle).build());
        items.add(doubleCircle);
        FactoryComponent ringGradient = new FactoryComponent(this);
        ringGradient.config(new RingGradientElement.RingGradientBuilder(ringGradient).build());
        items.add(ringGradient);
        FactoryComponent circleRing = new FactoryComponent(this);
        circleRing.config(new CircularRingElement.CircularRingBuild(circleRing).build());
        items.add(circleRing);
        FactoryComponent wifiLoading = new FactoryComponent(this);
        wifiLoading.config(new WifiLoadingElement.WifiBuilder(wifiLoading).build());
        items.add(wifiLoading);
        FactoryComponent ballJump = new FactoryComponent(this);
        ballJump.config(new BallJumpElement.BallJumpBuilder(ballJump).build());
        items.add(ballJump);
        FactoryComponent eatBeans = new FactoryComponent(this);
        eatBeans.config(new EatBeansElement.EatBeanBuilder(eatBeans).build());
        items.add(eatBeans);
        FactoryComponent dotLoading = new FactoryComponent(this);
        dotLoading.setAutoAnimation(false);
        dotLoading.config(new DotLoadingElement.DotLoadingBuilder(dotLoading).build());
        items.add(dotLoading);
        FactoryComponent ballBeat = new FactoryComponent(this);
        ballBeat.config(new BallBeatElement.BallBeatBuild(ballBeat).build());
        items.add(ballBeat);
        FactoryComponent ballDancer = new FactoryComponent(this);
        ballDancer.config(new BallDancerElement.BallDancerBuilder(ballDancer).build());
        items.add(ballDancer);
        FactoryComponent ballExchange = new FactoryComponent(this);
        ballExchange.config(new BallExchangeElement.BallExchangeBuilder(ballExchange).build());
        items.add(ballExchange);
        FactoryComponent chromeFloating = new FactoryComponent(this);
        chromeFloating.config(new ChromeFloatingCirclesElement.ChromeFloatingCirclesBuild(chromeFloating).build());
        items.add(chromeFloating);
        FactoryComponent chrysanthe = new FactoryComponent(this);
        chrysanthe.config(new ChrysantheElement.ChrysantheBuild(chrysanthe).build());
        items.add(chrysanthe);
        FactoryComponent folding = new FactoryComponent(this);
        folding.config(new FoldingCirclesElement.FoldingCirclesBuilder(folding).build());
        items.add(folding);
        FactoryComponent lineScale = new FactoryComponent(this);
        lineScale.config(new LineScaleElement.LineScaleBuilder(lineScale).build());
        items.add(lineScale);
        FactoryComponent location = new FactoryComponent(this);
        location.config(new LocatingLoadingElement.LocatingLoadingBuilder(location).build());
        items.add(location);
        FactoryComponent magnify = new FactoryComponent(this);
        magnify.config(new MagnifyElement.MagnifyBuilder(magnify).build());
        items.add(magnify);
        FactoryComponent overWatch = new FactoryComponent(this);
        overWatch.config(new OverWatchElement.OverWatchBuild(overWatch).build());
        items.add(overWatch);
        FactoryComponent stripLoading = new FactoryComponent(this);
        stripLoading.config(new StripLoadingElement.StripLoadingBuilder(stripLoading).build());
        items.add(stripLoading);
        FactoryComponent whorArc = new FactoryComponent(this);
        whorArc.config(new WhorArcLoadingElement.WhorArcLoadingBuilder(whorArc).build());
        items.add(whorArc);
        FactoryComponent sandClock = new FactoryComponent(this);
        sandClock.config(new SandClockElement.SandClockBuilder(sandClock).build());
        items.add(sandClock);
        FactoryComponent gear = new FactoryComponent(this);
        gear.config(new GearElement.GearBuilder(gear).build());
        items.add(gear);
    }


    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
